<script>
export default {
  name: 'DynCheckbox',
  model: {
    prop: 'value',
    event: 'change'
  },
  props: {
    value: {
      type: [String, Number, Boolean], // 验证类型后续可以增加
      default: ''
    },
    item: {
      type: Object,
      default: () => ({})
    }
  },
  methods: {
    handleChange(value) {
      this.$emit('change', value)
      // 执行事件对象
      this.item.event && this.item.event(value)
    }
  },
  render: function(h) {
    return (
      <el-checkbox
        value={this.value}
        on-change={this.handleChange.bind(this)}>
        {this.item.checkboxLabel}
      </el-checkbox>
    )
  }
}
</script>

